using System;
using System.Collections.Generic;
using System.Text;
using Excel = Microsoft.Office.Interop.Excel;
using System.Reflection;
namespace MacomberMap.Loader.Export
{
    /// <summary>
    /// This class provides an interface into an Excel workbook, to improve code readability
    /// </summary>
    public class MM_Excel_Worksheet
    {
        #region Variable declarations
        /// <summary>The Excel workbook upon which this is based</summary>
        public Excel.Worksheet BaseSheet;
        #endregion

        #region Initialization
        /// <summary>
        /// Initialize a new workbook
        /// </summary>
        /// <param name="BaseSheet">The workbsheet upon which the MM interface is based</param>
        public MM_Excel_Worksheet(Excel.Worksheet BaseSheet)
        {
            this.BaseSheet = BaseSheet;
        }
        #endregion

        #region Interfaces
        /// <summary>
        /// Retrieve a cell's information
        /// </summary>
        /// <param name="Row"></param>
        /// <param name="Column"></param>
        /// <returns></returns>
        public Excel.Range this[int Row, int Column]
        {
            get
            {
                return BaseSheet.Cells[Row, Column] as Excel.Range;
            }
        }

        

        /// <summary>
        /// Return the collection of hyperlinks
        /// </summary>
        public Excel.Hyperlinks Hyperlinks
        {
            get { return BaseSheet.Hyperlinks; }
        }

        /// <summary>
        /// Retrieve a range's information
        /// </summary>
        /// <param name="Row1"></param>
        /// <param name="Column1"></param>
        /// <param name="Row2"></param>
        /// <param name="Column2"></param>
        /// <returns></returns>
        public Excel.Range this[int Row1, int Column1, int Row2, int Column2]
        {
            get
            {
                return BaseSheet.Range[BaseSheet.Cells[Row1, Column1], BaseSheet.Cells[Row2, Column2]] as Excel.Range;
            }
        }

        /// <summary>
        /// Get/set the name of the sheet
        /// </summary>
        public String Name
        {
            get { return BaseSheet.Name; }
            set { BaseSheet.Name = value; }
        }

        /// <summary>
        /// Retrieve a row's information
        /// </summary>
        /// <param name="Row"></param>
        /// <returns></returns>
        public Excel.Range this [int Row]
        {
            get { return BaseSheet.Rows[Row, Missing.Value] as Excel.Range; }
        }

        /// <summary>
        /// Get the full list of cells in the document
        /// </summary>
        public Excel.Range Cells
        {
            get { return BaseSheet.Cells; }
        }
        #endregion


    }
}
